<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@taglib  prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<c:set var="ctx" value="${pageContext.request.contextPath}" />
<!DOCTYPE html>
<html lang="zh-cn">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
<meta name="renderer" content="webkit">
<title></title>
<link rel="stylesheet" href="../css/pintuer.css">
<link rel="stylesheet" href="../css/admin.css">
<script src="../js/jquery.js"></script>
<script src="../js/pintuer.js"></script>
</head>
<script type="text/javascript">
	$(function(){
		
		$(".button").click(function(){
			
			if($(".button").text().indexOf("修改")!=-1){
				//alert($(".button").text());
				$(".form-x")[0].action="${ctx }/advertising/update";
			}
		});	
		
		$("#location").change();
	})
	function change(e){
		var url = $(e).val();
		$("#url").attr("readonly","readonly");
		$("#url").val(url);
	}
	function showText(e){
		var location = $(e).val();
		if(location == 'home-line'){
			$("#url").removeAttr("readonly");
			$("#url").attr("rows","4");
			$("#url").attr("data-validate","length#<=150:不能大于50个文字");
		}else{
			$("#url").attr("readonly","readonly");
			$("#url").attr("rows","1");
		}
	}
</script>
<body>
<div class="panel admin-panel">
  <div class="panel-head" id="add"><strong><span class="icon-pencil-square-o">
  </span>
  <c:if test="${empty advertising}">
  	增加广告内容
  </c:if>	
  <c:if test="${!empty advertising}">
  	 修改广告内容
  </c:if>	
  </strong>
  </div>
  <div class="body-content">
    <form method="post" class="form-x" action="${ctx }/advertising/insert" enctype="multipart/form-data" id="form" >  
    <c:if test="${!empty advertising}">
  	  <input type="hidden" value="${advertising.id }" name="id">
    </c:if>	
    <div class="form-group">
        <div class="label">
          <label>广告位置：</label>
        </div>
        <div class="field" id="advertising">
           <select name="location"  class="input w50" id="location" onchange="showText(this)">
              	<option value="home-top" <c:if test="${advertising.location == 'home-top'}">selected</c:if>>首页顶部</option>
				<option value="home-line"  <c:if test="${advertising.location == 'home-line'}">selected</c:if>>首页信息列表</option>
				<option value="issue-center"  <c:if test="${advertising.location == 'issue-center'}">selected</c:if>>问题与回答间</option>
				<option value="issue-bottom"  <c:if test="${advertising.location == 'issue-bottom'}">selected</c:if>>全部回答结尾</option>
            </select>
          <div class="tips"></div>
        </div>
      </div>
	  <div class="form-group">
        <div class="label">
          <label>广告标题：</label>
        </div>
        <div class="field">
          <input type="text" class="input w50" value="${advertising.title }" name="title" data-validate="length#<=45:不能大于15个文字"/>
          <div class="tips"></div>
        </div>
      </div>
    <div class="form-group">
        <div class="label">
          <label>广告内容：</label>
        </div>
        <div class="field">
          <textarea readonly="readonly" rows="1" id="url" name="image" class="input tips" required style="width:25%; float:left;" data-toggle="hover" data-place="right" data-validate="required:广告内容">${advertising.image }</textarea>
		  <a class="button bg-blue input-file" href="javascript:void(0);" style="float:left;margin-left:10px;">+ 上传图片<input size="100" type="file" onchange="change(this)" name="file" accept=".jpg,.png,.jpeg,.gif" id="image" /></a>
		</div>
      </div> 
	  
	  <div class="form-group">
        <div class="label">
          <label>图片链接：</label>
        </div>
        <div class="field">
          <input type="text" class="input w50" value="${advertising.link }" name="link"  >
          <div class="tips"></div>
        </div>
      </div>
      
      <div class="form-group">
        <div class="label">
          <label>广告描述：</label>
        </div>
        <div class="field">
          <textarea  class="input" rows="5"  name="describe"  data-validate="length#<=75:不能大于25个文字" >${advertising.describe }</textarea>
          <div class="tips"></div>
        </div>
      </div>
       <c:if test="${empty advertising}">
	  <div class="form-group">
        <div class="label">
          <label>显示：</label>
        </div>
        <div class="field" style="padding: 10px 7px 7px 0px;">
          <input type="checkbox" value="1" name="status"  />
          <div class="tips"></div>
        </div>
      </div>
      </c:if>
      <div class="form-group">
        <div class="label">
          <label></label>
        </div>
        <div class="field">
          <button class="button bg-main icon-check-square-o" type="submit">
            <c:if test="${!empty advertising}">
            	修改
        	</c:if>
         	 <c:if test="${empty advertising}">
				增加
         	 </c:if>
           </button>
        </div>
      </div>
    </form>
  </div>
</div>

</body></html>